//go:build wireinject
// +build wireinject

package server

import (
	"github.com/google/wire"
	"go-caipu/pkg/api"
	"go-caipu/pkg/bus"
	"go-caipu/pkg/infra/localcache"
	"go-caipu/pkg/infra/remotecache"
	"go-caipu/pkg/infra/tracing"
	"go-caipu/pkg/registry"
	"go-caipu/pkg/server/backgroundsvcs"
	"go-caipu/pkg/services/admin/auth"
	"go-caipu/pkg/services/admin/config"
	"go-caipu/pkg/services/admin/config/configimpl"
	"go-caipu/pkg/services/admin/dept"
	"go-caipu/pkg/services/admin/dept/deptimpl"
	"go-caipu/pkg/services/admin/dict"
	"go-caipu/pkg/services/admin/dict/dictimpl"
	"go-caipu/pkg/services/admin/menu"
	"go-caipu/pkg/services/admin/menu/menuimpl"
	"go-caipu/pkg/services/admin/post"
	"go-caipu/pkg/services/admin/post/postimpl"
	"go-caipu/pkg/services/admin/role"
	"go-caipu/pkg/services/admin/role/roleimpl"
	apiSer "go-caipu/pkg/services/admin/sysapi"
	"go-caipu/pkg/services/admin/sysapi/apiimpl"
	apiSerImpl "go-caipu/pkg/services/admin/sysapi/apiimpl"
	"go-caipu/pkg/services/admin/systemlog"
	systemImpl "go-caipu/pkg/services/admin/systemlog/impl"
	sysUser "go-caipu/pkg/services/admin/sysuser"
	userImpl "go-caipu/pkg/services/admin/sysuser/userimpl"
	"go-caipu/pkg/services/auth/authattempt"
	"go-caipu/pkg/services/auth/authattempt/authattemptimpl"
	"go-caipu/pkg/services/datasources"
	datasourcesImpl "go-caipu/pkg/services/datasources/services"
	"go-caipu/pkg/services/grpcserver"

	"go-caipu/pkg/services/monitor/onlineuser"
	onlineuserImpl "go-caipu/pkg/services/monitor/onlineuser/impl"

	"go-caipu/pkg/services/pluginsintegration"
	sysJob "go-caipu/pkg/services/schedule"
	sysJobimpl "go-caipu/pkg/services/schedule/impl"
	"go-caipu/pkg/services/secrets"
	"go-caipu/pkg/services/secrets/secretsimpl"
	"go-caipu/pkg/services/sqlstore"
	"go-caipu/pkg/services/sqlstore/migrations"
	"go-caipu/pkg/services/tools"
	"go-caipu/pkg/services/tools/toolsimpl"
	"go-caipu/pkg/setting"

	storage "go-caipu/pkg/services/storage/service"
)

/*
⚠️注意：只有方法引用的包在 wire.Build 范围内，才会被 wire 工具注入。
*/

var wireBasicSet = wire.NewSet(
	setting.NewCfgFromArgs,
	New,
	migrations.ProvideOSSMigrations,
	wire.Bind(new(registry.DatabaseMigrator), new(*migrations.OSSMigrations)),
	sqlstore.ProvideService,
	bus.ProvideBus,
	wire.Bind(new(bus.Bus), new(*bus.InProcBus)),
	localcache.ProvideService,
	remotecache.ProviceRedisClient,
	remotecache.ProvideCache,
	api.ProvideHTTPServer,
	onlineuserImpl.ProvideService,
	wire.Bind(new(onlineuser.Service), new(*onlineuserImpl.Service)),

	tracing.ProvideService,
	backgroundsvcs.ProvideBackgroundServiceRegistry,
	wire.Bind(new(registry.BackgroundServiceRegistry), new(*backgroundsvcs.BackgroundServiceRegistry)),
	userImpl.ProvideService,
	wire.Bind(new(sysUser.Service), new(*userImpl.Service)),
	authattemptimpl.ProvideService,
	wire.Bind(new(authattempt.Service), new(*authattemptimpl.Service)),
	auth.ProvideService,
	wire.Bind(new(auth.Authenticator), new(*auth.AuthenticatorService)),
	menuimpl.ProvideService,
	wire.Bind(new(menu.Service), new(*menuimpl.Service)),
	roleimpl.ProvideService,
	wire.Bind(new(role.Service), new(*roleimpl.Service)),
	deptimpl.ProvideService,
	wire.Bind(new(dept.Service), new(*deptimpl.Service)),
	postimpl.ProvideService,
	wire.Bind(new(post.Service), new(*postimpl.Service)),
	apiimpl.ProvideService,
	wire.Bind(new(apiSer.Service), new(*apiSerImpl.Service)),
	toolsimpl.ProvideService,
	wire.Bind(new(tools.Service), new(*toolsimpl.Service)),
	dictimpl.ProvideService,
	wire.Bind(new(dict.Service), new(*dictimpl.Service)),
	configimpl.ProvideService,
	wire.Bind(new(config.Service), new(*configimpl.Service)),
	secretsimpl.ProvideSecretsService,
	wire.Bind(new(secrets.Service), new(*secretsimpl.SecretsService)),

	systemImpl.ProvideService,
	wire.Bind(new(systemlog.Service), new(*systemImpl.Service)),
	pluginsintegration.WireSet,
	datasourcesImpl.ProvideService,
	wire.Bind(new(datasources.Service), new(*datasourcesImpl.Service)),
	sysJobimpl.ProvideService,
	wire.Bind(new(sysJob.Service), new(*sysJobimpl.Service)),
	grpcserver.ProviderService,
	grpcserver.ProvideAdminService,
	storage.NewStorageService,
)
var wireSet = wire.NewSet(
	wireBasicSet,
)

func Initialize(cla setting.CommandLineArgs, opts Options, apiOpts api.ServerOptions) (*Server, error) {
	wire.Build(wireSet)

	return &Server{}, nil
}

//success
//PS D:\gitee\HaoHao\go-caipu> wire gen -tags oss ./pkg/server
